package com.chaodev.base.model;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.handler.inter.IExcelDataModel;
import cn.afterturn.easypoi.handler.inter.IExcelModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Objects;

/**
 * @author lccccc
 * 继承IExcelModel, IExcelDataModel以获取校验结果,增加errorMsg,rowNum两个参数。
 */
@ApiModel("excel导入测试")
public class Student implements IExcelModel, IExcelDataModel {
    @ApiModelProperty("文件标识（uuid）")
    private String id;

    @ApiModelProperty("姓名")
    @Excel(name = "姓名")
    // 正则校验
    @Pattern(regexp = "[\u4E00-\u9FA5]*", message = "不是中文")
    private String name;

    @ApiModelProperty("班级")
    @Excel(name = "班级")
    private String classes;

    @ApiModelProperty("性别")
    @Excel(name = "性别")
    // 非空
    @NotNull(message = "不能为空")
    private String sex;

    @ApiModelProperty("成绩")
    @Excel(name = "成绩")
    @Max(value = 100,message = "最大值不能超过100")
    private Double score;

    @ApiModelProperty("地址")
    @Excel(name = "地址")
    private String area;

    @ApiModelProperty("邮政编码")
    @Excel(name = "邮政编码")
    // 长度
//    @Length(min = 1 , max = 8 , message = "不能为空且长度需要在1至6位")

    private String code;

    @ApiModelProperty("手机号")
    @Excel(name = "手机号")
    // 长度
//    @Length(min = 1 , max = 11 , message = "不能为空且长度需要在1至11位")
    private String phone;

    @ApiModelProperty("创建用户")
    private String createUser;

    @ApiModelProperty("创建时间")
    private String createTime;

    private String errorMsg;

    private Integer rowNum;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Student student = (Student) o;
        return Objects.equals(id, student.id) && Objects.equals(name, student.name) && Objects.equals(classes, student.classes) && Objects.equals(sex, student.sex) && Objects.equals(score, student.score) && Objects.equals(area, student.area) && Objects.equals(code, student.code) && Objects.equals(phone, student.phone) && Objects.equals(createUser, student.createUser) && Objects.equals(createTime, student.createTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, classes, sex, score, area, code, phone);
    }

    @Override
    public String toString() {
        return name + ' ' + classes + ' ' + sex + ' ' + score + ' ' + area + ' ' + code + ' ' + phone;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getClasses() {
        return classes;
    }

    public void setClasses(String classes) {
        this.classes = classes;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    public String getArea() {
        return area;
    }

    public void setArea(String area) {
        this.area = area;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCreateUser() {
        return createUser;
    }

    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public Student() {
    }

    public Student(String id, String name, String classes, String sex, Double score, String area, String code, String phone, String createUser, String createTime) {
        this.id = id;
        this.name = name;
        this.classes = classes;
        this.sex = sex;
        this.score = score;
        this.area = area;
        this.code = code;
        this.phone = phone;
        this.createUser = createUser;
        this.createTime = createTime;
    }

    @Override
    public Integer getRowNum() {
        return rowNum;
    }

    @Override
    public void setRowNum(Integer rowNum) {
        this.rowNum = rowNum;
    }

    @Override
    public String getErrorMsg() {
        return errorMsg;
    }

    @Override
    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
}
